package lec14dfs;

import java.util.Arrays;

public class DfsPermulationApp {
    static int n = 9;
    static int[] a = new int[n];
    static int[] book = new int[n];

    static void dfs(int k) {
        if (k == n) {
            int X = a[0] * 100 + a[1] * 10 + a[2];
            int Y = a[3] * 100 + a[4] * 10 + a[5];
            int Z = a[6] * 100 + a[7] * 10 + a[8];
            if (Y == 2 * X && Z == 3 * X) {
                System.out.println(Arrays.toString(a));
            }
            return;//
        }
        for (int i = 0; i < n; i++) {
            if (book[i] == 1)
                continue;//
            a[k] = i + 1;
            book[i] = 1;
            dfs(k + 1);
            book[i] = 0;//
        }

    }

    public static void main(String[] args) {
        dfs(0);

    }

}
